/*
PearReview - The peer review assistant.
Copyright (C) 2009  Dimitrij Pankratz, Anton Musichin
http://www.pearreview.com, info@pearreview.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package com.pearreview.ui;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;

import javax.swing.JPanel;

/**
 * For displaying the panels with forms. Contains a simple gradient in the
 * background.
 *
 */
public class PearPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5251285532007729836L;
	private Color startColor = new Color(0xd6d6d6);
	private Color endColor = new Color(0xa9a9a9);
	
	//private Color startColor = new Color(0xededed);
	//private Color endColor = new Color(0xa9a9a9);
	
	public PearPanel() {
		super();
	}
	
	public void revertColor(boolean revert) {
		if (revert) {
			startColor = new Color(0xbfd72b);
			endColor = new Color(0xbfd72b);
		} else {
			startColor = new Color(0xd6d6d6);
			endColor = new Color(0xa9a9a9);
		}
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		/*
		Graphics2D g2 = (Graphics2D) g;
		super.paintComponent(g);
		GradientPaint p;
		p = new GradientPaint(0, 0, startColor,
		0, getHeight(), endColor);
		Paint oldPaint = g2.getPaint();
		g2.setPaint(p);
		g2.fillRect(0, 0, getWidth(), getHeight());
		g2.setPaint(oldPaint);
		*/
		
		Graphics2D g2 = (Graphics2D) g;
		super.paintComponent(g);
		GradientPaint p;
		p = new GradientPaint(0, 0, startColor, 0, 500, endColor);
		Paint oldPaint = g2.getPaint();
		g2.setPaint(p);
		g2.fillRect(0, 0, getWidth(), getHeight());
		g2.setPaint(oldPaint);
	}
}
